home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 8
/
Amoszine 8 (Disk 3 of 3).adf
/
Andy_Smith.lha
/
DirStruc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-07-24
|
1KB
|
79 lines
#include <stdio.h>
#include <string.h>
#include <dos/dos.h>
#include <exec/exec.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
BOOL ScanDisk(char *directory);
FILE *fopen(), *out_file;
void main(int argc, char *argv[])
{
char search_dir[64];
char outputfile[64];
printf("Directory Scanner - Thrown together by Andy Smith\n");
printf("A nice hack for Steve Bye\n\n");
if (argc != 3)
{
printf("Excuse me pal, I am missing some arguments\n");
printf("USAGE: dirstruc <directory> <output file>\n\n");
return;
}
strcpy(search_dir, *++argv);
strcpy(outputfile, *++argv);
out_file = fopen(outputfile,"w");
printf("Scanning directory %s.......\n",search_dir);
if (!(ScanDisk(search_dir)))
printf("Whoops! Sommats gone wrong\n\n");
printf("Scanning complete, writing to file %s\n",outputfile);
return;
}
BOOL ScanDisk(char *directory)
{
#ifdef _DCC
__aligned struct FileInfoBlock fib;
#else
struct FileInfoBlock __aligned fib;
#endif
BPTR lock;
char full_path[255];
if (!(lock = Lock(directory, ACCESS_READ))) return FALSE;
if (!(Examine(lock, &fib))) return FALSE;
while (ExNext(lock, &fib))
{
strcpy(full_path, directory);
AddPart(full_path, fib.fib_FileName, 255);
if (fib.fib_DirEntryType > 0)
{
if (!(ScanDisk(full_path)))
{
UnLock(lock);
return FALSE;
}
}
else
{
/* Save the filename to a data file */
strcat(full_path,"\n");
fputs(full_path, out_file);
}
}
UnLock(lock);
return TRUE;
}